/*
 * Copyright (C), 2002-2017, 上海亦寻信息技术有限公司
 * FileName: ProjectPremisesIndustDataServiceFacadeImpl.java
 * Author:   linyao
 * Date:     2017-3-10 下午4:06:09
 * Description: //模块目的、功能描述      
 * History: //修改记录
 * <author>      <time>      <version>    <desc>
 * 修改人姓名             修改时间            版本号                  描述
 */
package com.emm.yixun.estate.service.impl;

import java.util.List;

import javax.jws.WebService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.emm.yixun.basic.service.ProjectPremisesIndustDataService;
import com.emm.yixun.basic.service.ProjectRoomService;
import com.emm.yixun.common.model.ProjectPremisesIndustData;
import com.emm.yixun.common.model.dto.ProjectPremisesIndustDataDto;
import com.emm.yixun.common.page.Page;
import com.emm.yixun.common.response.Response;
import com.emm.yixun.common.response.ResponseList;
import com.emm.yixun.estate.service.ProjectPremisesIndustDataServiceFacade;

/**
 * 〈一句话功能简述〉 〈功能详细描述〉
 * 
 * @author linyao
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
@Service("projectPremisesIndustDataServiceFacade")
@WebService(name = "com.emm.yixun.estate.service.ProjectPremisesIndustDataServiceFacade")
public class ProjectPremisesIndustDataServiceFacadeImpl implements ProjectPremisesIndustDataServiceFacade {
	private final Logger logger = LoggerFactory.getLogger(this.getClass());
	@Autowired
	private ProjectPremisesIndustDataService projectPremisesIndustDataService;
	
	@Autowired
	private ProjectRoomService projectRoomService;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.emm.yixun.estate.service.ProjectPremisesIndustDataServiceFacade#save(com.emm.yixun.common.model.dto.
	 * ProjectPremisesIndustDataDto)
	 */
	@Override
	public Response<ProjectPremisesIndustDataDto> save(ProjectPremisesIndustDataDto dto) {
		Response<ProjectPremisesIndustDataDto> response = new Response<ProjectPremisesIndustDataDto>();
		response.setSuccess(Boolean.FALSE);
		try {
			ProjectPremisesIndustDataDto entity=projectPremisesIndustDataService.create(dto);
			response.success(entity);
		} catch (Exception e) {
			logger.error("ProjectPremisesIndustDataServiceFacadeImpl save error: ", e);
		}
		return response;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.emm.yixun.estate.service.ProjectPremisesIndustDataServiceFacade#updateByPrimaryKey(com.emm.yixun.common.model
	 * .dto.ProjectPremisesIndustDataDto, java.lang.Boolean)
	 */
	@Override
	public Response<Integer> updateByPrimaryKey(ProjectPremisesIndustDataDto dto, Boolean selective) {
	    	Response<Integer> response = new Response<Integer>();
	    	response.setEntity(projectPremisesIndustDataService.update(dto));
		return response;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.emm.yixun.estate.service.ProjectPremisesIndustDataServiceFacade#deleteByPrimaryKey(java.lang.Long)
	 */
	@Override
	public Response<Integer> deleteByPrimaryKey(Long id) {
	    Response<Integer> response = new Response<Integer>();
	    try {  
    	    	ProjectPremisesIndustDataDto entity = new ProjectPremisesIndustDataDto();
    	    	entity.setId(id);
    	    	response.setEntity(projectPremisesIndustDataService.destroy(entity));
	    } catch (Exception e) {
		logger.info("ProjectPremisesIndustDataServiceFacadeImpl deleteByPrimaryKey error: ", e);
	    }
	    return response;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.emm.yixun.estate.service.ProjectPremisesIndustDataServiceFacade#findById(java.lang.Long)
	 */
	@Override
	public Response<ProjectPremisesIndustData> findById(Long id) {
	    Response<ProjectPremisesIndustData> response = new Response<ProjectPremisesIndustData>();
	    response.setEntity(projectPremisesIndustDataService.selectById(id));
	    return response;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.emm.yixun.estate.service.ProjectPremisesIndustDataServiceFacade#findByDto(com.emm.yixun.common.model.dto.
	 * ProjectPremisesIndustDataDto)
	 */
	@Override
	public ResponseList<ProjectPremisesIndustData> findByDto(ProjectPremisesIndustDataDto dto) {
		ResponseList<ProjectPremisesIndustData> responseList = new ResponseList<ProjectPremisesIndustData>();
		responseList.setSuccess(Boolean.FALSE);
		try {
			List<ProjectPremisesIndustData> list = projectPremisesIndustDataService.selectListByDto(dto);
			responseList.success(list);
		} catch (Exception e) {
			logger.error("ProjectPremisesIndustDataServiceFacadeImpl findByDto error: ", e);
		}
		return responseList;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.emm.yixun.estate.service.ProjectPremisesIndustDataServiceFacade#findPageByDto(com.emm.yixun.common.model.
	 * dto.ProjectPremisesIndustDataDto, java.lang.Integer, java.lang.Integer)
	 */
	@Override
	public Page<ProjectPremisesIndustData> findPageByDto(ProjectPremisesIndustDataDto dto, Integer begin, Integer row) {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.emm.yixun.estate.service.ProjectPremisesIndustDataServiceFacade#destroy(com.emm.yixun.common.model.dto.
	 * ProjectPremisesIndustDataDto)
	 */
	@Override
	public Response<Boolean> destroy(ProjectPremisesIndustDataDto dataDto) {
		Response<Boolean> response = new Response<Boolean>();
		response.setSuccess(Boolean.FALSE);
		try {
			projectPremisesIndustDataService.destroy(dataDto);
			response.setSuccess(Boolean.TRUE);
		} catch (Exception e) {
			logger.error("ProjectPremisesIndustDataServiceFacadeImpl destory error: ", e);
		}
		return response;
	}

	/**
	 * 根据项目ID或组团ID查询业态数据
	 * 
	 * @param projectId，premisesId
	 * @return ProjectPremisesIndustData
	 */
	@Override
	public ProjectPremisesIndustData selectIndustData(Long projectId,
			Long premisesId) {
		return projectPremisesIndustDataService.selectIndustData(projectId, premisesId);
	}

	@Override
	public List<String> groupByIndustMark(Long premisesId) {
		return projectRoomService.groupByIndustMark(premisesId);
	}

	@Override
	public ResponseList<ProjectPremisesIndustData> queryIndustByBuilding(Long projectId, Long premisesId,String industType) {
	    ResponseList<ProjectPremisesIndustData> responseList = new ResponseList<ProjectPremisesIndustData>();
	    try {
		List<ProjectPremisesIndustData> entity = projectPremisesIndustDataService.queryIndustByBuilding(projectId, premisesId,industType);
		responseList.setSuccess(true);
		responseList.setEntity(entity);
	    } catch (Exception e) {
		responseList.setSuccess(false);
		logger.error("ProjectPremisesIndustDataServiceFacadeImpl queryIndustByBuilding error: ", e);
	    }
	    return responseList;
	}

	@Override
	public ResponseList<ProjectPremisesIndustData> queryIndustSum(Long projectId, Long premisesId, String industType) {
	    ResponseList<ProjectPremisesIndustData> responseList = new ResponseList<ProjectPremisesIndustData>();
	    try {
		List<ProjectPremisesIndustData> entity = projectPremisesIndustDataService.queryIndustSum(projectId, premisesId,industType);
		responseList.setSuccess(true);
		responseList.setEntity(entity);
	    } catch (Exception e) {
		responseList.setSuccess(false);
		logger.error("ProjectPremisesIndustDataServiceFacadeImpl queryIndustSum error: ", e);
	    }
	    return responseList;
	}

}
